<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use  HasFactory, Notifiable;
    protected $table = 'user';
    protected $guarded = [];

    public function find($id)
    {
        return $this->where('uid',$id)->first();
    }

    /**
     * @param $uid
     * @return mixed
     * 查询用户指定余额
     */
    public static function findMoney($uid){
        return self::where('uid',$uid)->value('now_money');
    }

    /**
     * @param $uid
     * @param $money
     * @return mixed
     * 修改余额
     */
    public static function UpMoney($uid,$money){
        return self::where('uid',$uid)->update([
            'now_money' =>$money
        ]);
    }

    /**
     * @param $uid
     * 获取当前用户信息
     */
    public static function information($uid){
        return self::select('real_name','card_id','phone')->where('uid',$uid)->first()->toarray();
    }
    /**
     * api
     * @param $data
     * @return mixed
     * 修改团长佣金所得
     */
    public static function upGroupBossPrice($data){
        return self::where("uid",$data['uid'])->update(["brokerage_price"=>$data['brokerage_price']]);
    }

    /**
     * @param $uid
     * @return mixed
     * 查询团长佣金
     */
    public static function groupDataPrice($uid){
        return self::where("uid",$uid)->first("brokerage_price");
    }

    /**
     * @param $uid
     * 查询修改用户信息
     */
    public static function findUser($uid){
        return self::where('uid',$uid)->first();
    }
}
